package com.joker.demo.admin.config;


import com.joker.demo.core.config.JobSchedulerProperties;
import com.joker.demo.core.scheduler.JobScheduler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * job启动服务类
 *
 * @author : feixiang.li
 * @since : 2025-07-27 16:18
 */
@Slf4j
@Configuration
public class JobConfig {

    @Value("${job.scheduler.port}")
    private Integer port = 9999;

    @Value("${job.scheduler.boss-threads}")
    private Integer bossThreads;

    @Value("${job.scheduler.worker-threads}")
    private Integer workerThreads;


    @Bean
    public JobScheduler jobSchedulerHelper() {
        JobSchedulerProperties jobSchedulerProperties = new JobSchedulerProperties();
        jobSchedulerProperties.setPort(port);
        jobSchedulerProperties.setBossThreads(bossThreads);
        jobSchedulerProperties.setWorkerThreads(workerThreads);
        log.info("jobSchedulerProperties: {}", jobSchedulerProperties);
        return new JobScheduler(jobSchedulerProperties);
    }
}
